package atguigu2.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @AUTHOR LYF
 * @DATE 2022/2/4
 * @VERSION 1.0
 * @DESC
 * 1. 线程池的架构及其创建方式
 * 2.
 */
public class ThreadPoolDemo {
    public static void main(String[] args) {
        // 一次N线程
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        //new ThreadPoolExecutor(nThreads, nThreads,
//        0L, TimeUnit.MILLISECONDS,
//                new LinkedBlockingQueue<Runnable>());

        // 一池一线程
        ExecutorService executorService1 = Executors.newSingleThreadExecutor();

        // 可扩容


        for (int i = 0; i < 10; i++) {
            final int num = i;
            executorService.execute(()->{
                System.out.println(Thread.currentThread().getName()+"办理业务"+num);
            });
        }
        executorService.shutdown();
    }
}
